package com.huatie.controller;

import com.huatie.service.KafkaProducerService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * @ClassName KafkaTestController
 * @Description //TODO
 * @Author yangyuanping
 * @Date 2025/4/25 23:40
 **/
@RestController
@RequestMapping("/kafka")
public class KafkaTestController {
    private final KafkaProducerService producerService;

    public KafkaTestController(KafkaProducerService producerService) {
        this.producerService = producerService;
    }

    @PostMapping("/send")
    public String sendMsg(@RequestParam String message) {
        producerService.sendMessage("test-topic", message);
        return "Message sent: " + message;
    }
}
